<?php $post = $this->get('post');?>
<form action="<?php _actionUrl($this)?>" onsubmit="return ajax_form(this)" method="post" onreset="calendar_check_day($('#dfi').k(0))">
<input type="hidden" value="<?php _e($post['ID'])?>" name="ID"/>
<div class="x-list-title"> 
<table height="100%" width="100%" border="0" cellpadding="0">
<tr><td>
<h2>Lịch cơ quan mới</h2>
</td>
<td align="right">
	<div class="x-list-options">
	</div>
</td>
</tr></table>
</div>
<div class="x-form-container">
<div class="form-message"></div>
<table width="100%" border="0" cellpadding="0" class="x-form">
<tr>
	<td width="100" class="x-form-label">
		Tiêu đề:
	</td>
	<td class="x-form-input">
		<input name="title" type="text" class="x-text" style="width:400px" value="<?php _e( $post['title']);?>"/>
	</td>
</tr>
<tr>
	<td class="x-form-label">
		Ngày thực hiện:
	</td>
	<td class="x-form-input">
		<input autocomplete="off" name="date_start" onclick="date_picker(this,{noTime:true})" onblur="calendar_fill_date_end(this)" type="text" class="x-text x-date" size="10" value="<?php _e(show_date(DATE_FORMAT,$post['date_start']))?>"/>
	</td>
</tr>
<tr>
	<td class="x-form-label">
		Thời gian:
	</td>
	<td class="x-form-input">
		Từ <input autocomplete="off" onclick="time_picker(this)" type="text" class="x-text x-time" size="7" name="time_start" value="<?php _e( show_date('H:i',$post['time_start']) );?>"/>
		
		 đến <input autocomplete="off" onclick="time_picker(this)" type="text" class="x-text x-time" size="7" name="time_end" value="<?php _e( show_date('H:i',$post['time_end']) );?>"/> 
	</td>
</tr>
<tr>
	<td width="100" class="x-form-label">
		Địa điểm:
	</td>
	<td class="x-form-input">
		<input name="place" type="text" class="x-text" style="width:400px" value="<?php _e($post['place'])?>"/>		
	</td>
</tr>
<tr>
	<td class="x-form-label">
		Người tạo:
	</td>
	<td class="x-form-input">
		<?php _e(get_user_link($this->get('user')))?>
	</td>
</tr>
<tr>
	<td width="100" class="x-form-label">
		Chủ trì:
	</td>
	<td class="x-form-input">
		<input name="chairman" type="text" class="x-text" style="width:400px" value="<?php _e($post['chairman'])?>"/>		
	</td>
</tr>
<tr>
	<td width="100" class="x-form-label">
		Thành phần tham gia:
	</td>
	<td class="x-form-input">
		<input name="guests" type="text" class="x-text" style="width:400px" value="<?php _e($post['guests'])?>"/>		
	</td>
</tr>
<tr>
	<td width="100" class="x-form-label">
		Chuẩn bị:
	</td>
	<td class="x-form-input">
		<input name="tools" type="text" class="x-text" style="width:400px" value="<?php _e($post['tools'])?>"/>		
	</td>
</tr>
<tr>
	<td class="x-form-label">
		Nội dung:
	</td>
	<td class="x-form-input">
		<textarea class="x-text x-editor" name="content" style="width:610px;height:100px"><?php _e($post['content'])?></textarea>	
	</td>
</tr>
<tr>
	<td class="x-form-label">
		Thông báo tới:
	</td>
	<td class="x-form-input">
		<?php _e(tpl_select_users('users[]','',$this->get('users')));?>
	</td>
</tr>
<tr>
	<td class="x-form-label">
		Thông báo qua SMS:
	</td>
	<td class="x-form-input">
		<div class="x-sms">
			<div class="h">
				<label>
					<input onclick="$(this.parentNode.parentNode.parentNode).find('.hd').toggle();$(this.parentNode.parentNode.parentNode).find('textarea').set('disabled', !this.checked )" class="x-checkbox" type="checkbox"/> 
					Sử dụng
				</label>	
			</div>
		<div style="display:none" class="hd">	
		<textarea maxlength="160" disabled="disabled" name="sms_content" placeholder="Nội dung tin nhắn SMS, tối đa 160 ký tự ..."></textarea>
		<div style="padding:10px 0px">Thêm số từ danh bạ: </div>	
		<?php 
			_e(tpl_auto_select(array(
				name	=>	'sms_phone[]',
				type 	=>  'automutiply',
				url 	=>	 baseUrl().'/User/Sms',
				title	=>	'title',
				link 	=> 	''
			)));
		?>
		</div>	
		</div>
	</td>
</tr>
<tr>
	<td class="x-form-label">
		Nhắc nhở:
	</td>
	<td class="x-form-input">
		<input class="x-checkbox" type="checkbox" name="repeat_alert" value="yes"<?php _e($post['repeat_alert']=='yes' ? ' checked':'')?>/> Thông báo
		&nbsp;<input type="checkbox" name="repeat_email" value="yes"<?php _e($post['repeat_email']=='yes' ? ' checked':'')?>/> Gửi email 
		&nbsp;<input type="checkbox" name="repeat_sms" value="yes"<?php _e($post['repeat_email']=='yes' ? ' checked':'')?>/> Gửi SMS 
		&nbsp;&nbsp; Trước
		<select name="repeat_time_number" class="x-select">
			<option value="0"<?php _e($post['repeat_time_number']=='0' ? ' selected':'')?>>0</option>
			<option value="1"<?php _e($post['repeat_time_number']=='1' ? ' selected':'')?>>1</option>
			<option value="2"<?php _e($post['repeat_time_number']=='0' ? ' selected':'')?>>2</option>
			<option value="5"<?php _e($post['repeat_time_number']=='5' ? ' selected':'')?>>5</option>
			<option value="10"<?php _e($post['repeat_time_number']=='10' ? ' selected':'')?>>10</option>
			<option value="30"<?php _e($post['repeat_time_number']=='30' ? ' selected':'')?>>30</option>
		</select>		
		<select name="repeat_time_unit" class="x-select">
			<option value="1"<?php _e($post['repeat_time_unit']=='1' ? ' selected':'')?>>phút</option>	
			<option value="60"<?php _e($post['repeat_time_unit']=='60' ? ' selected':'')?>>giờ</option>	
			<option value="1440"<?php _e($post['repeat_time_unit']=='1440' ? ' selected':'')?>>ngày</option>	
			<option value="10080"<?php _e($post['repeat_time_unit']=='10080' ? ' selected':'')?>>tuần</option>	
		</select>		
	</td>
</tr>
<tr>
	<td class="x-form-label" valign="top">
		Tùy chỉnh lặp:
	</td>
	<td class="x-form-input">
		<table cellpadding="10" width="100%">
		<tr>
			<td align="right">
				Kiểu lặp lại:<sup class="hint" title="Lặp hàng tuần: sự kiện lặp vào thứ của ngày đã chọn">[?]</sup> 
			</td>
			<td>
				<input onclick="calendar_check_day(this)" type="radio" name="repeat_type" value="none"<?php _e($post['repeat_type']=='none' ? ' checked':'')?>/> Không lặp
				<input onclick="calendar_check_day(this)" type="radio" name="repeat_type" value="day"<?php _e($post['repeat_type']=='day' ? ' checked':'')?>/> Hàng ngày
				<input onclick="calendar_check_day(this)" type="radio" name="repeat_type" value="week"<?php _e($post['repeat_type']=='week' ? ' checked':'')?>/> Hàng tuần
				<input onclick="calendar_check_day(this)" type="radio" name="repeat_type" value="month"<?php _e($post['repeat_type']=='month' ? ' checked':'')?>/> Hàng tháng
				<input onclick="calendar_check_day(this)" type="radio" name="repeat_type" value="year"<?php _e($post['repeat_type']=='year' ? ' checked':'')?>/> Hàng năm
			</td>
		</tr><tr>		
			<td align="right">
				Chọn thứ:<sup class="hint" title="Chỉ có hiệu lực nếu chọn kiểu lặp theo ngày">[?]</sup> 
			</td>
			<td id="cday">
				<?php 
					$disabled = $post['repeat_type'] != 'day' ? ' disabled ' : ' '; 
					$rp = explode(',',$post['repeat_day']);	
				?>
				<input<?php _e($disabled);?>type="checkbox" name="repeat_day[]" id="dfi" value="1"<?php in_array('1',$rp ) ? _e(' checked') :'' ?>/>Thứ 2
				<input<?php _e($disabled);?>type="checkbox" name="repeat_day[]" value="2"<?php in_array('2',$rp ) ? _e(' checked') :'' ?>/>Thứ 3
				<input<?php _e($disabled);?>type="checkbox" name="repeat_day[]" value="3"<?php in_array('3',$rp ) ? _e(' checked') :'' ?>/>Thứ 4
				<input<?php _e($disabled);?>type="checkbox" name="repeat_day[]" value="4"<?php in_array('4',$rp ) ? _e(' checked') :'' ?>/>Thứ 5
				<input<?php _e($disabled);?>type="checkbox" name="repeat_day[]" value="5"<?php in_array('5',$rp ) ? _e(' checked') :'' ?>/>Thứ 6
				<input<?php _e($disabled);?>type="checkbox" name="repeat_day[]" value="6"<?php in_array('6',$rp ) ? _e(' checked') :'' ?>/>Thứ 7
				<input<?php _e($disabled);?>type="checkbox" name="repeat_day[]" value="0"<?php in_array('0',$rp ) ? _e(' checked') :'' ?>/>Chủ nhật
			</td>
		</tr><tr>		
			<td align="right">
				Ngày kết thúc lặp:
			</td>
			<td id="cday">
				<input name="repeat_date_end" id="d-end" onclick="date_picker(this,{noTime:true});this._focused=true" type="text" class="x-text x-date" size="10" value="<?php _e(show_date(DATE_FORMAT,$post['repeat_date_end']));?>"<?php _e( $post['repeat_type'] == 'none' ? ' disabled ' : '');?>/>						
			</td>						
		</tr>
		</table>									
	</td>
</tr>
<tr>
	<td></td>
	<td>
		<?php _e(tpl_button_add('Cập nhật'));?>
		<?php _e(tpl_button_back('Hủy bỏ','#Calendar/Company/View?ID='.$post['ID']));?>
	</td>
</tr>
</table></div>
</form>